package com.gitee.wsl.ext.list


fun <T> List<T>.countWhile(predicate: (T) -> Boolean): Int {
    val i = this.indexOfFirst { !predicate(it) }
    return if (i >= 0) i else this.size
}

fun <T> List<T>.countLastWhile(predicate: (T) -> Boolean): Int {
    val i = this.indexOfLast { !predicate(it) }
    return if (i >= 0) (this.size - 1 - i) else this.size
}
